package com.ch01;

/**
 * This class illustrates class instantiation and referencing
 * @author Mahesh
 *
 */
public class Basic {
	private int no1 = 10;
	
	public static void main(String args[]) {
		//Create the first instance
		Basic b1 = new Basic();
		b1.setNo1(30);
		System.out.println(b1.getNo1());
		
		//Create the 2nd instance
		Basic b2 = new Basic();
		System.out.println(b2.getNo1());
		
		//Assign first instance to point to 2nd instance
		b1 = b2;
		System.out.println(b1.getNo1() + "," + b2.getNo1());
		
		//Now change the 2nd object
		b2.setNo1(300);
		System.out.println(b1.getNo1() + "," + b2.getNo1());
	}

	public int getNo1() {
		return no1;
	}

	public void setNo1(int no1) {
		this.no1 = no1;
	}
}
